<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"
	dir="ltr">
<head>
<title>Moment Mobile Payments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/styles/layout.css" type="text/css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>

<script src="<%=request.getContextPath()%>/js/validation.js"></script>
<script>
	function showbank() {
		var a = $("#instrumenttype option:selected").text();
		if (a == "Account") {
			$(".bank").show();
			$(".card").hide();
			$(".mmid").hide();
			$(".loyalty").hide();
			
		} else if(a=="Card") {
			$(".card").show();
			$(".bank").hide();
			$(".mmid").hide();
			$(".loyalty").hide();
		}else if(a=="MMID"){
			$(".mmid").show();
			$(".bank").hide();
			$(".card").hide();
			$(".loyalty").hide();
		}else{
			$(".loyalty").show();
			$(".bank").hide();
			$(".card").hide();
			$(".card").hide();
		}

	}
</script>

</head>
<body id="top">
	<%@include file="loggedinheader.jsp"%>
	<%@ page import="org.json.*"%>
	<%@ page import="com.moment.model.*"%>
	<%@ page import="org.json.*"%>
	<%@ page import="com.moment.model.*"%>
	<%@page import="com.moment.webservice.*"%>
	<%@page import="com.moment.util.Converter"%>
	<%@page import="java.util.HashMap"%>
	<%@page import="java.util.Map"%>
	<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONArray"%>

	<%@ page language="java" contentType="text/html; charset=UTF-8"
		pageEncoding="UTF-8"%>
	<%@page import="java.util.*"%>
	<%!String s[];%>

	You are not logged in
	<br />
	<a href="index.jsp">Please Login</a>
	<jsp:useBean id="userObj" class="com.moment.model.UserReg"
		scope="session" />
	<div class="wrapper col3">

		<div id="intro">
			<div id="logout">
				<a href="/MMP/LogoutController"><img
					src="<%=request.getContextPath()%>/images/logout.png" alt="Logout" /></a>
			</div>
			<div class="fl_left1">

				<div id="login1">
					<div class="imgl">
						<img alt="Embedded Image" height="128" width="128"
							src="data:image/jpeg;base64,<jsp:getProperty name="userObj" property="imagestr" />" />
					</div>
				</div>
				<div id="instrumentsmain">
					<div>

						<h2>
							<center>Add Instrument</center>
						</h2>
					</div>
					<style>
.control-label {
	display: inline-block;
	width: 250px;
}

.control-group {
	padding-bottom: 10px;
}

.help-inline {
	padding-left: 255px;
}
</style>
					<form id="instruForm" action="../CardController" method="post">
					<!-- for all instrument name -->
						<div class="control-group">
							<label class="control-label" for="nickname">Instrument
								Name:</label> <input name="nickname" id="nickname" type="text"
								maxlength="15" class="required" /> <span style="display: none;"
								class="help-inline">Please fill instrument name</span>

						</div>
						
						<div class="control-group">
							<label class="control-label" for="instrumenttype">Instrument
								Type:</label> <select id="instrumenttype" name="instrumenttype"
								onchange="showbank();">
								<option value="Card">Card</option>
								<option value="Account">Account</option>
							<!-- 	<option value="MMID">MMID</option>
								<option value="Loyaltypoint">Loyalty Points</option> -->
								
							</select>

						</div>
						<!-- For card -->
						<div class="control-group card">
							<label class="control-label" for="cardtype">Card Type:</label> <select
								id="cardtype" name="cardtype">
								<option value="debit">Debit Card</option>
								<option value="credit">Credit Card</option>
							</select>

						</div>
						<div class="control-group card">
							<label class="control-label" for="cardno">Card No.:</label> <input
								name="cardno" id="cardno" type="text" maxlength="16"
								class="required card" /> <span style="display: none;"
								class="help-inline">Please enter valid card number</span>

						</div>
						<div class="control-group card">
							<label class="control-label" for="cardexpiry">Card Expiry
								Date:</label> Month: <select name="expirym">
								<%
									for (int i = 1; i <= 12; i++) {
										String j = String.valueOf(i);
										if (String.valueOf(i).length() == 1) {
											j = "0" + String.valueOf(i);
										}

										out.println("<option value='" + j + "'>" + j + "</option>");
									}
								%>

							</select> &nbsp; Year:&nbsp; <select name="expiryy">
								<%
									for (int i = 2014; i <= 2034; i++) {
										out.println("<option value='" + i + "'>" + i + "</option>");
									}
								%>
							</select> <span style="display: none;" class="help-inline">Please
								select expiry date</span>

						</div>
						<!-- Account Details -->
						<div class="control-group bank" style="display: none;">
							<label class="control-label" for="bankAccno">Account No.:</label>

							<input type="text" name="bankAccno" id="bankAccno"
								class="required" /> <span style="display: none;"
								class="help-inline">Please enter bank account number.</span>

						</div>
						<div class="control-group bank" style="display: none;">
							<label class="control-label" for="bankName">Bank Name:</label> <input
								type="text" name="bankName" id="bankName" class="required" /> <span
								style="display: none;" class="help-inline">Please enter
								bank name.</span>

						</div>
						<div class="control-group bank" style="display: none;">
							<label class="control-label" for="acctype">Account Type:</label>

							<select id="acctype" name="acctype">
								<option value="Saving">Saving</option>
								<option value="Current">Current</option>
							</select>

						</div>
						<!-- MMID CARD  -->
						<div class="control-group mmid" style="display: none;">
							<label class="control-label" for="mmidno">MMID No:</label>
							 <input
								name="mmidno" id="mmidno" type="text" maxlength="16"
								class="required" /> <span style="display: none;"
								class="help-inline">Please enter valid card number</span>

						</div>
						<div class="control-group mmid" style="display: none;">
							<label class="control-label" for="mmidbankname">Bank Name:</label> <input
								name="mmidbankname" id="mmidbankname" type="text" maxlength="16"
								class="required" /> <span style="display: none;"
								class="help-inline">Please enter valid card number</span>

						</div>
						<div class="control-group mmid" style="display: none;">
							<label class="control-label" for="mmidacctype">Account Type:</label>

							<select id="mmidacctype" name="mmidacctype">
								<option value="Saving">Saving</option>
								<option value="Current">Current</option>
							</select>

						</div>
						<!--Loyalty Card  -->
						<div class="control-group loyalty" style="display: none;">
							<label class="control-label" for="loyaltyno">Loyalty Card No:</label>
							 <input
								name="loyaltyno" id="loyaltyno" type="text" maxlength="16"
								class="required" /> <span style="display: none;"
								class="help-inline">Please enter valid card number</span>

						</div>
						<div class="control-group loyalty" style="display: none;">
							<label class="control-label" for="issuer">Issuer Name:</label> <input
								name="issuer" id="issuer" type="text" maxlength="16"
								class="required" /> <span style="display: none;"
								class="help-inline">Please enter valid card number</span>

						</div>
						<!-- All Needed -->
						<div class="control-group">
							<label class="control-label" for="currency">Currency:</label> <select
								id="currency" name="currency" style="width:235px">
								<%
									//--New CODE-------------
									Map<String, String> map = new HashMap<String, String>();
									map.put("method", "34");
									map.put("mnum", (String) session.getAttribute("username"));

									String json = new Converter().mapToJson(map);
									System.out.println("json String :" + json);
									Services serviceproxy = new ServicesProxy();

									String currency = serviceproxy.service(json);
									// ---------------------------
									/* WebsProxy ws = new WebsProxy();
									String mnumber = (String) session.getAttribute("username");
									String location = ws.fetchLocation(mnumber); */
									JSONArray jArray;
									JSONObject jobj = null;
									try {
										jArray = new JSONArray(currency);
										for(int i=0;i<jArray.length();i++)
										{
										jobj = jArray.getJSONObject(i);
									
										out.println("<option value='" + jobj.getString("id") + "'>" + jobj.getString("country")+" - "+jobj.getString("currencySymbol")+ "</option>");
								
										}
										
									} catch (JSONException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
								%>	</select><span style="display: none;" class="help-inline">Please
									enter numeric values only.</span>
						</div>
						<div class="control-group">
							<label class="control-label" for="instruDlimit">Instrument
								Daily Limit:</label> <input type="text" name="instruDlimit"
								id="instruDlimit" value="2000" class="required numeric" /> <span
								style="display: none;" class="help-inline">Please enter
								numeric values only.</span>

						</div>
						<div class="control-group">
							<label class="control-label" for="instruMlimit">Instrument
								Monthly Limit:</label> <input type="text" name="instruMlimit"
								id="instruMlimit" value="20000" class="required numeric" /> <span
								style="display: none;" class="help-inline">Please enter
								numeric values only.</span>

						</div>
						<div class="fl_right">
							<input type="hidden" id="updateorsave" name="updateorsave"
								value="save" /> <input type="submit" class="myButton"
								value="Submit" />
						</div>
					</form>




				</div>

			</div>
		</div>
	</div>
	<br class="clear" />


	<%@include file="footer.jsp"%>


</body>
</html>

